package co.yixiang.yshop.module.product.dal.mysql.storeproductassure;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.module.product.controller.admin.storeproductassure.vo.StoreProductAssureExportReqVO;
import co.yixiang.yshop.module.product.controller.admin.storeproductassure.vo.StoreProductAssurePageReqVO;
import co.yixiang.yshop.module.product.dal.dataobject.storeproductassure.StoreProductAssureDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 商品保障服务 Mapper
 *
 * @author admin
 */
@Mapper
public interface StoreProductAssureMapper extends BaseMapperX<StoreProductAssureDO> {

    default PageResult<StoreProductAssureDO> selectPage(StoreProductAssurePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX
                <StoreProductAssureDO>()
                .likeIfPresent(StoreProductAssureDO::getName, reqVO.getName())
                .eqIfPresent(StoreProductAssureDO::getContent, reqVO.getContent())
                .eqIfPresent(StoreProductAssureDO::getSorted, reqVO.getSorted())
                .eqIfPresent(StoreProductAssureDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(StoreProductAssureDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StoreProductAssureDO::getId));
    }

    default List<StoreProductAssureDO> selectList(StoreProductAssureExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX
                <StoreProductAssureDO>()
                .likeIfPresent(StoreProductAssureDO::getName, reqVO.getName())
                .eqIfPresent(StoreProductAssureDO::getContent, reqVO.getContent())
                .eqIfPresent(StoreProductAssureDO::getSorted, reqVO.getSorted())
                .eqIfPresent(StoreProductAssureDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(StoreProductAssureDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StoreProductAssureDO::getId));
    }

}
